/**
 * Scoped function
 */
var currentsec=0;
var currentmin=0;
var currenthour=0;

var Strsec="00";
var	Strmin="00";
var	Strhour="00";

var keepgoin=false;

/**
 *
 */
function timer() {

	if(keepgoin) {
		currentsec+=1;

		if (currentsec==60) {
			currentsec=0;
			currentmin+=1;
		}

		if (currentmin==60) {
			currentmin=0;
			currenthour+=1;
		}

		setTimeout("timer()", 1000);
	}

	Strhour=""+currenthour;
	Strmin=""+currentmin;
	Strsec=""+currentsec;

	if (Strsec.length!=2) {
		Strsec="0"+currentsec;
	}

	if (Strmin.length!=2) {
		Strmin="0"+currentmin;
	}

	$("#chrono-seconds").html(Strsec);
	$("#chrono-minutes").html(Strmin);
	$("#chrono-hour").html(Strhour);
}

/**
 * Function to start
 */
function startover(time,start) {

	if(time) {
		currentsec = time % 60
		currentmin = ((time - currentsec) / 60)|0;

		if(currentmin >= 60) {
			currentmin = currentmin % 60
			currenthour = (currentmin / 60)|0 +1
		} else {
			currenthour = 0
		}
	} else {
		currentsec=0;
		currentmin=0;
		currenthour=0;
	}

	keepgoin=start;

	Strsec="00";
	Strmin="00";
	Strhour="00";

	timer();
}